<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_detail.css">

    <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" >
    <!-- <script src="js/jquery.min.js"></script> -->
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
</head>
<body>
    <div class="nav">
        <img src="img/元宵汤圆.png" alt="">
        <span class="title">我的博客系统</span>
        <!-- spacer不显示任何内容,只是占位,把后面的a标签撑到后面去 -->
        <div class="spacer" style="width: 65%"></div>
        <a href="blog_list.html" >主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="#" id="delete-btn">删除博客</a>
        <a href="cancellation">注销</a>
    </div>
    <!-- 这个div表示页面的主区域(版心) -->
    <div class="container">
        <!-- 左侧用户信息 -->
        <div class="container-left">
            <!-- 用这个元素表示用户的信息 -->
            <div class="card" >
                <img src="img/20201227170738_9f5ea.gif" alt="">
                <h3>哒哒</h3>
                <a href="https://gitee.com/tvt-yuan">gitee地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span class="blogcount"></span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!-- 右侧内容区域 -->
        <div class="container-right">
            <div class="blog-detail">
                <h3></h3>
                <div class="date">
                    
                </div>
                <p id="content" style="background-color: transparent">
                    
                </p>
            </div>
        </div>
    </div>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="js/login.js"></script>
    <script>
        function getUsers() {
            $.ajax({
                type: 'get',
                url: 'user' + location.search,
                contentType: 'appliaction/json;charset=utf8',
                success: function(body) {
                    let cardDiv = document.querySelector('.card');
                    let h3Div = document.querySelector('.card>h3');
                    h3Div.innerHTML = body.userName;

                    let spanDiv = document.querySelector('.counter>.blogcount')
                    spanDiv.innerHTML = body.userBlog;
                }
            });
        }
        function getBlog() {
            $.ajax({
                type: 'get',
                url: 'DetailServlet' + location.search,
                contentType: 'application/json;charset=utf8',
                success : function(body) {
                    let detailDiv = document.querySelector('.container-right>.blog-detail');

                    let h3Div = document.querySelector('.container-right>.blog-detail>h3');
                    h3Div.innerHTML = body.title;

                    let dateDiv = document.querySelector('.container-right>.blog-detail>.date');
                    dateDiv.innerHTML = body.postTime;

                    // let pDiv = document.querySelector('.container-right>.blog-detail>p');
                    // pDiv.innerHTML = body.content;

                    editormd.markdownToHTML('content',{ markdown: body.content });

                }
            });
        }
        
        function updatedelete() {
            let delete_btn = document.querySelector("#delete-btn");
            delete_btn.href = 'drop' + location.search;
        }

        getLogin();
        getUsers();
        getBlog();
        updatedelete();
        
    </script>
    
</body>
</html>